package vivace.view;

import java.awt.*;

import javax.swing.*;
import javax.sound.midi.*;

import vivace.helper.GUIHelper;

public class EventBar extends JPanel {

	private String name;
	private int width,height;
	
	public int getWidth(){
		return this.width;
	}
	
	public void setWidth(int width){
		this.width = width;
		if(width < 5)
			this.width = 5; // Prevent short notes from being invisible...
		this.setPreferredSize(new Dimension(width,this.height));
		repaint();
	}

	public EventBar( String name ){
		this.setOpaque(false);
		this.height = GUIHelper.NOTE_HEIGHT;
		this.name = name;
	}
	
	public void paintComponent(Graphics g){
		super.paintComponent(g);
		g.setColor(Color.GREEN);
		g.fillRect(0, 0, this.width, this.height);
		g.setColor(Color.BLACK);
		g.drawString(this.name,0,6);
	}
	
	public void setPosition( int x, int y ){
		setBounds(x,y,this.width,this.height);
	}
	
}
